package com.example.first.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.first.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface UserMapper extends BaseMapper<User> {
    @Select("select * from user")
    List<User> findAll();
    @Insert("INSERT INTO user(name,age,identity,phone) VALUES (#{name},#{age},#{identity},#{phone})")
     int  insert(User user);
     @Update("update user set name= #{name},age=#{age},identity=#{identity},phone=#{phone}")
    int update(User user);
     @Delete("delete from user where id=#{id}")
    Integer deleteById(@Param("id") Integer id);
     @Select("select * from user where name like concat('%',#{name},'%') limit #{pageNum},#{pageSize}")
     List<User> selectPage(Integer pageNum,Integer pageSize,String name);
    @Select("select count(*) from user where name like concat('%',#{name},'%')")
    Integer selectTotal(String name);

    @Select("select age,name from user")
    List<User> findStream();
}
